﻿
using DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAl
{
    public class UserService
    {
        /// <summary>
        /// 从数据库查询
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public static User GetUser(string u)
        {
            using (ShopContext db = new ShopContext())
            {
                var user = db.User.SingleOrDefault(p => p.ZhangHao == u);
                return user;
            }
        }
        /// <summary>
        /// 将 User 对象数据保存回数据库
        /// </summary>
        /// <param name="user"></param>
        public static void Save(User user)
        {
            using (ShopContext db = new ShopContext())
            {
                db.SaveChanges();
            }
        }
    }
}
